
import csv

class reed_csv():
    def read_data_from_csv(self, filepath):

        # 读取csv文件中数据
        with open(filepath, 'r') as f:
            datas = csv.reader(f)
            # # 如果有标题行跳过
            # next(datas, None)
            # 定义一个空列表，用于存放数据
            lis = []
            # 使用一个for循环把文件中的datas中的数据读取存入lis中
            for item in datas:
                lis.append(item)

            # 删除标题行
            lis.pop(0)
            print('数据', lis)
            return lis

# tt = reed_csv()
# tt.read_data_from_csv('edit_mm.csv')



from openpyxl import load_workbook

# 方法1：读取Excel文件数据
class read_data_from_excel():

    def __init__(self, path, sheetname):
        self.path = load_workbook(path)
        self.sheetname = self.path[sheetname]

    def getdata(self):
        datalist = []
        for item in self.sheetname:
            list = []
            list.append(item[0].value)
            list.append(item[1].value)
            datalist.append(list)

        datalist.pop(0)
        return datalist


# path = r'E:\zhuangaoer_pyCharm\zhuangaowuday1\A3mall_pytest\birthday.xlsx'
# sheetname = 'Sheet1'
# dy = read_data_from_excel(path, sheetname)
# print(dy.getdata())



